import axiosInstance from "../axiosInstance";


const foodInfo = {
    /**
     * 分类查询菜品信息
     * @param {{ pageIndex, food_name, category_name }} param0 
     * @returns {Promise<Object>}
     */
    getListByPage({ pageIndex, food_name, category_name }) {
        return axiosInstance.get("/foodInfo/getListByPage", {
            params: {
                pageIndex, food_name, category_name
            }
        })
    },
    /**
     * 菜品权重设置
     * @param {{id,weight}} param0 
     * @returns {Promise<Object>}
     */
    setFoodInfoWeight({ id, weight }) {
        return axiosInstance.get("/foodInfo/setFoodInfoWeight", {
            params: {
                id, weight
            }
        })
    },
    /**
     * 新增菜品内容
     * @param {{ food_name, price, cid, food_desc, food_img, weight }} param0 
     * @returns {Promise<Object>}
     */
    add({ food_name, price, cid, food_desc, food_img, weight }) {
        return axiosInstance.post("/foodInfo/add", {
            food_name, price, cid, food_desc, food_img, weight
        })
    },
    /**
     * 根据id删除菜品信息
     * @param {id} id 
     * @returns 
     */
    deleteById(id) {
        return axiosInstance.get("/foodInfo/deleteById", {
            params: {
                id
            }
        })
    },
    /**
     * 根据id得到菜品内容
     * @param {id} param0 
     * @returns {Promise<Object>}
     */
    findById(id) {
        return axiosInstance.get("/foodInfo/findById", {
            params: {
                id
            }
        })
    },
    /**
     * 更新菜品信息
     * @param {{ id, food_name, price, cid, food_desc, food_img, weight }} param0 
     * @returns 
     */
    update({ id, food_name, price, cid, food_desc, food_img, weight }) {
        return axiosInstance.post("/foodInfo/update", {
            id, food_name, price, cid, food_desc, food_img, weight
        })
    }
}

export default foodInfo;